package com.yang.design.create.singletonPattern;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

/**
 * 反射对单例模式的破坏
 */
public class Test_Reflect {
    public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class<Singleton_05> clazz = Singleton_05.class;
        Constructor<Singleton_05> constructor = clazz.getDeclaredConstructor(null);
        constructor.setAccessible(true);
        Singleton_05 instance1 = constructor.newInstance();
        Singleton_05 instance2 = constructor.newInstance();
        System.out.println(instance1);
        System.out.println(instance2);
    }
}
